import service from '@/utils/request';
//场景拓扑组件列表
export const getComponent = params =>
  service({
    url: `/simulation/resourceLibrary/component/sceneTopo/`,
    method: 'get',
    params: params,
  });
//获取画布详情
export const getTopologyDetail = (id) =>
  // service({ // 老接口
  //   url: `/simulation/scene/scene/${id}/`,
  //   method: 'get',
  // });
  service({ // 新接口
    url: `/scene_topo/scene?id=${id}`,
    method: 'get',
  });
  
//新增节点
export const editorNode = (id, data) =>
  service({
    url: `/simulation/scene/scene/${id}/instance/`,
    method: 'post',
    data,
  });
//修改节点
export const editorPutNode = (data) => {
  service({
    url: `api/verify/topo/`,
    method: 'put',
    data,
  });
}
  // service({
  //   url: `/simulation/scene/scene/${id}/instance/${oid}/topo/`,
  //   method: 'put',
  //   data,
  // });
  
//新增连线
export const editorLink = (id, data) =>
  service({
    url: `/simulation/scene/scene/${id}/instanceLink/`,
    method: 'post',
    data,
  });
//删除连线
export const deleteLink = (id, oid, data) =>
  service({
    url: `/simulation/scene/scene/${id}/instanceLink/${oid}/`,
    method: 'delete',
    data,
  });
//修改连线
export const editorPutLink = (id, oid, data) =>
  service({
    url: `/simulation/scene/scene/${id}/instanceLink/${oid}/`,
    method: 'put',
    data,
  });
//删除节点
export const deleteNode = (id, oid, data) =>
  service({
    url: `/simulation/scene/scene/${id}/instance/${oid}/`,
    method: 'delete',
    data,
  });
/**
 * @description 场景列表
 * @returns
 */
export const getSceneList = params => {
  return service({
    url: '/scene_topo/get',
    method: 'get',
    params: params,
  });
};
export const addSceneList = data => {
  return service({
    url: '/simulation/scene/scene/',
    method: 'post',
    data,
  });
};
export const editSceneList = data => {
  return service({
    url: `/simulation/scene/scene/${data.id}/`,
    method: 'put',
    data,
  });
};
export const delSceneList = id => {
  return service({
    url: `/simulation/scene/scene/${id}/`,
    method: 'delete',
  });
};
/**
 * @description topo节点详情
 * @returns
 */
export const getDescFunc = params => {
  return service({
    url: `/simulation/scene/scene/${params.id}/instance/${params.uuid}/`,
    method: 'get',
  });
};

/**
 * @description 场景副本topo节点详情
 * @returns
 */
export const getCopyDescFunc = params => {
  return service({
    url: `/simulation/scene/scene/copy/${params.id}/instance/${params.uuid}/`,
    method: 'get',
  });
};

export const setDescFunc = data => {
  return service({
    url: `/simulation/scene/scene/${data.id}/instance/${data.uuid}/`,
    method: 'put',
    data,
  });
};
export const setCopyDescFunc = data => {
  return service({
    url: `/simulation/scene/scene/copy/${data.id}/instance/${data.uuid}/`,
    method: 'put',
    data,
  });
};
// 生成场景
export const generateScene = data => {
  return service({
    url: `/simulation/scene/scene/${data.id}/`,
    method: 'post',
    data,
  });
};

//实例console画面
export const getVirtual = (id, RID, params) => {
  return service({
    url: `/simulation/scene/scene/${id}/instance/${RID}/console/`,
    method: 'get',
    params,
  });
};

//副本实例console画面
export const getCopyVirtual = (id, RID, params) => {
  return service({
    url: `/simulation/scene/scene/copy/${id}/instance/${RID}/console/`,
    method: 'get',
    params,
  });
};

//操作实例
export const editScene = (id, RID, data) => {
  return service({
    url: `/simulation/scene/scene/${id}/instance/${RID}/`,
    method: 'post',
    data,
  });
};
//操作实例
export const editSceneCopy = (id, RID, data) => {
  return service({
    url: `/simulation/scene/scene/copy/${id}/instance/${RID}/`,
    method: 'post',
    data,
  });
};
//场景重置
export const resetScene = id => {
  return service({
    url: `/simulation/scene/scene/${id}/reset/`,
    method: 'post',
  });
};
//场景开启/关闭
export const openScene = (id, data) => {
  return service({
    url: `/simulation/scene/scene/${id}/operation/`,
    method: 'post',
    data,
  });
};
//场景转存
export const transferScene = (id, data) => {
  return service({
    url: `/simulation/scene/scene/${id}/transfer/`,
    method: 'post',
    data,
  });
};
//获取场景类型
export const getSceneType = () => {
  return service({
    url: `/scene/type`,
    method: 'get',
  });
};

//获取系统列表
export const getSystemList = () => {
    return service({
        url: `/simulation/scene/scene/systemList/`,
        method: 'get',
    });
};

//获取当前实例的可连接实例
export const getInstanceLinkOption = (id, instanceID) => {
  return service({
    url: `/simulation/scene/scene/${id}/instanceLinkOption/${instanceID}/`,
    method: 'post',
  });
};

//实例上传文件
export const instanceSendFile = (id, RID, data) =>
  service({
    url: `/simulation/scene/scene/${id}/instance/${RID}/file/`,
    method: 'post',
    data,
  });

// 获取工具分类
export const getToolType = () => {
    return service({
        url: `/simulation/resourceLibrary/tool/type/`,
        method: 'get',
    });
};

// 获取工具列表
export const getToolList = (params) => {
    return service({
        url: `/simulation/resourceLibrary/tool/`,
        method: 'get',
        params
    });
};

/**
 * 获取攻击路径
 * @param id
 * @param params
 * @returns {*}
 */
export const getAttackPathApi = (id, params) => {
    return service({
        url: `/simulation/scene/scene/${id}/attackPath/`,
        method: 'get',
        params
    });
};

/**
 * 删除攻击路径
 * @param id
 * @param rID
 * @returns {*}
 */
export const delAttackPathApi = (id, rID) => {
    return service({
        url: `/simulation/scene/scene/${id}/attackPath/${rID}/`,
        method: 'delete'
    });
};

/**
 * 新增攻击路径
 * @param id
 * @param data
 * @returns {*}
 */
export const addAttackPathApi = (id, data) => {
    return service({
        url: `/simulation/scene/scene/${id}/attackPath/`,
        method: 'post',
        data
    });
};

/**
 * 获取场景实例列表
 * @returns {*}
 */
export const getSceneInstanceApi = (id, params) => {
    return service({
        url: `/simulation/scene/scene/${id}/instance/`,
        method: 'get',
        params
    });
};

// 分页查询集群列表
export const getCluster = data =>
    service({
      url: '/simulation/res/cluster/',
      method: 'get',
      params: data,
    });

    /**
 * 批量导出到资源库
 * @param data
 * @returns {*}
 */
export const exportSceneVersionToResourceApi = data =>
    service({
        url: `/simulation/scene/scene/version/batchTransfer/`,
        method: 'post',
        data
    });

    /**
 * 获取所有场景版本
 * @param params
 * @returns {*}
 */
export const getSceneVersionAllApi = params =>
    service({
        url: `/simulation/scene/scene/version/`,
        method: 'get',
        params
    });

export const getEquipmentList = () =>
    service({
        url: `/simulation/resourceLibrary/equipment/`,
        method: 'get',
    });

    /**
 * @desc 场景列表
 * @param {*} params
 * @returns
 */
export const getScenesList = params => {
    return service({
      url: '/simulation/resourceLibrary/scene/',
      method: 'get',
      params,
    });
};
  
/**
 * @desc 场景导入
 * @param {Object} params
 * @param {Number} params.sceneID
 * @param {Object} params.data
 * @param {Number} params.data.clusterID
 * @param {Object} params.data.computer
 * @param {Object} params.data.network
 * @returns
 */
export const importScenes = ({ sceneID, data }) => {
    return service({
      url: `/simulation/resourceLibrary/scene/${sceneID}/import/`,
      method: 'post',
      data,
    });
};
  

export const uploadMyGraphicsFile = data =>
  service({
    url: `/simulation/system/upload/`,
    method: 'post',
    headers: {
      'Content-Type': 'multipart/form-data',
    },
    data,
  });

  // 单个集群详情
export const getByID = id =>
  service({
    url: `/simulation/res/cluster/${id}/`,
    method: 'get',
  });

  export const getMaterialLinkCheck = data =>
    service({
        url: `/simulation/res/localMaterial/linkCheck/`,
        method: 'post',
        data
    });

export const getComponentType = () =>
service({
  url: '/simulation/resourceLibrary/component/type/',
  method: 'get'
});

export const deleteACL = aclID =>
  service({
    url: `/simulation/res/network/acl/${aclID}/`,
    method: 'delete',
  });
export const addAcl = data =>
  service({
    url: '/simulation/res/network/acl/',
    method: 'post',
    data,
  });